#!/usr/bin/python

# This function accepts input in form of absolute path for a directory, 
# checks if the directory exists or is it a valid path or not
# If it is a valid path then it will move to caluclate the number of files in that directory 
# including sub-directories

# *** If it is not a valid path, it will give file count of 0. I have to modify that and its getting late
# and I am tired. Its my first day of doing some serious pythong programming and
# DVS (Distributed version control) as well

# You might be thinking what a bad way of counting number of files in a directory
# Actually I am trying to write a module which can be used to search a particular pattern 
# in all files in a given directory for which I need to read all the files
# More to come.......

import os


def main():
 a = raw_input('Directory: ')
 print 'Is Directory:', os.path.isdir(a)
 # print a
 result = list()
 for dirpath, dirnames, filenames in os.walk(a):
  for name in filenames:
   fullpath = os.path.join(dirpath, name)
   result.append(fullpath)
 # result([],[],[]) = os.walk(a)
 # print result
 print 'Number of files:', len(result)


if __name__ == '__main__':
 main()

